package com.czm.art_light.patterns.chainOfResponsibility.impl;

import com.czm.art_light.constant.CommonConsts;
import com.czm.art_light.context.UserActionStrategyContext;
import com.czm.art_light.param.request.UserActionReqDto;
import com.czm.art_light.patterns.chainOfResponsibility.UserActionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 更新统计数据处理器
 */
@Component
public class UpdateStatsHandler implements UserActionHandler {
    @Autowired
    private UserActionStrategyContext userActionStrategyContext;

    @Override
    public void handle(UserActionReqDto userActionReqDto) {
        // 更新相关艺术作品的统计数据
        userActionStrategyContext.getSaveOrderStrategy(userActionReqDto.getActionType().getValue()).updateStatisticsData(userActionReqDto);
    }

    @Override
    public Integer sort() {
        return CommonConsts.ChainSortEnum.SORT_2.getSort();
    }
}